package com.lzw.breezeNovel.webApp.controller.comic;

import com.lzw.breezeNovel.common.result.Result;
import com.lzw.breezeNovel.webApp.service.comic.ComicRatingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * @author 清风明月
 * @Package com.lzw.breezeNovel.webApp.controller.comic
 * @date 2025/3/17
 * @description 漫画评分
 */
@RestController
@RequestMapping("/app/comicRating")
@SuppressWarnings("all")
public class ComicRating {

   /**
    * 注入service
    */
   @Autowired
   private ComicRatingService comicRatingService;

   /**
    * 漫画评分
    */
   @RequestMapping("/rating")
   public Result rating(@RequestParam Long comicId, @RequestParam Double rating){
      comicRatingService.rating(comicId,rating);
      return Result.ok();
   }

   /**
    * 根据用户id或亲戚评分
    */
   @RequestMapping("/getRatingByUserId")
   public Result getRatingByUserId(@RequestParam Long comicId){
       BigDecimal socre = BigDecimal.valueOf(comicRatingService.getRatingByUserId(comicId));
       return Result.ok(socre);
   }
}
